﻿import axios from 'axios';
import request from '@/utils/request.js';

export function getAllUserService(pageCondition) {

    //同步等待响应 async await
    //获取用户所有数据
    /* return await axios.get('http://localhost:8080/user/queryUserList')
         .then(result => {
             return result.data;
         }).catch(err => {
 
         });*/
    //return request.get('http://localhost:8080/user/queryUserList');
    return request.get('/user/queryLimitUserList', { params: pageCondition });
}

export function getUserByNameGenderService(condition) {
    /*return axios.get('http://localhost:8080/user/queryUserByNameAndGender', {id:condition.id, uname:condition.uname, gender:condition.gender})
        .then(result => {
            return result.data;
        }).catch(err => {

        });*/
    return request.get('/user/queryUserByNameAndGender', { uname: condition.uname, gender: condition.gender });
}

/**
 * 
 * 新增用户信息
 * @param {any} condition
 * @returns
 */
export function addNewUserService(condition) {
    return request.post('/user/addNewUser', { uname: condition.uname, gender: condition.gender });
}

/**
 * 编辑用户信息
 * @param {any} condition
 * @returns
 */
export function editNewUserService(condition) {
    return request.post('/user/updateUser', { id: condition.id, uname: condition.uname, gender: condition.gender });
}